package com.txh.blog.controller;

import com.txh.blog.bean.Blog;
import com.txh.blog.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
public class ArchivesController{
   @Autowired
   private BlogService blogService;

    @RequestMapping("/archives")
    public String archives(Model model){
        Map<String, List<Blog>> archives = blogService.archives();
        model.addAttribute("archives",archives);
        model.addAttribute("blogCount",blogService.blogCount());
        return "archives";
    }
}
